package com.enjoylearning.content.feignClient.fallBack;

import com.enjoylearning.content.feignClient.SearchClient;
import com.enjoylearning.content.feignClient.po.CourseIndex;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class SearchClientFallbackFactory implements FallbackFactory<SearchClient> {
    @Override
    public SearchClient create(Throwable throwable) {
        return new SearchClient() {
            @Override
            public Boolean add(CourseIndex courseIndex) {
                log.debug("添加es文档发生熔断，文档信息:{},异常:{}",courseIndex,throwable.toString(),throwable);
                return false;
            }
        };
    }
}
